package com.mxchip.livestarmobile.mobile.duobeiyun;


import com.duobeiyun.paassdk.media.DBAudioSource;
import com.duobeiyun.paassdk.media.DBIAudioFrameCustom;
import com.mxchip.livestarmobile.mobile.util.Log.MyLog;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author : create by yanggaosheng$
 * @time : 2019-10-10$
 * @des :  自定义视频源$
 **/
public class CustomAudioSource implements DBAudioSource {

    private Map<String, DBIAudioFrameCustom> frameCustomMap = new ConcurrentHashMap<>();
    public Map<String, DBIAudioFrameCustom> getFrameCustomMap() {
        return frameCustomMap;
    }

    @Override
    public void onAudioSourceInit(String deviceName, DBIAudioFrameCustom dbiAudioFrameCustom) {
        if (null == deviceName || "".equals(deviceName)) {
            deviceName = "default";
        }
        MyLog.logD(MyLog.CUSTOM_AUDIO_SOURCE_MODEL,"CustomVideoSource::"+"onVideoSourceInit: "+deviceName);
        frameCustomMap.put(deviceName, dbiAudioFrameCustom);
    }

    @Override
    public void onAudioSourceDestroy(String deviceName) {
        if (null == deviceName || "".equals(deviceName)) {
            deviceName = "default";
        }
        MyLog.logD(MyLog.CUSTOM_AUDIO_SOURCE_MODEL,"CustomAudioSource::"+"onAudioSourceDestroy: ");
        frameCustomMap.remove(deviceName);
    }
}
